package com.zhdl.modules.process.dto;

import com.zhdl.modules.process.common.*;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@Data
public class ProcessBean {
    private String desc;
    private long sTime;
    private long eTime;
    /**
     * step = -1 是流程结束标记 执行过以后停止
     */
    private Integer step;
    private ProcessDo processDo;
    private AfterVerify afterVerify;
    private ProcessVerify processVerify;
    private List<ProcessVerify> processVerifyList = new ArrayList<>();
    private AfterCurrentProcessDo afterCurrentProcessDo;
    private ProcessTimeout processTimeout;
    private boolean reTryDo;
    private int timeout = -1;
    private int produceTime;
    private int runStatus = 0;
    private long pre_time = 0;
    private boolean isShow = true;
    private int reTryCount = 3;
    private boolean processOk = true;




    public ProcessBean(String desc, Integer step, long pre_time) {
        this.desc = desc;
        this.step = step;
        this.pre_time = pre_time;
    }

    public ProcessBean(String desc, Integer step) {
        this.desc = desc;
        this.step = step;
    }
    public ProcessBean(String desc) {
        this.desc = desc;
        this.step = -1;
    }
    public ProcessBean addDoSomeThing(ProcessDo processDo){
        this.processDo = processDo;
        return this;
    }
    public ProcessBean addAfterVerify(AfterVerify afterVerify){
        this.afterVerify = afterVerify;
        return this;
    }
    public ProcessBean addAfterProcess(AfterCurrentProcessDo afterCurrentProcessDo){
        this.afterCurrentProcessDo = afterCurrentProcessDo;
        return this;
    }

    public ProcessBean isShow(boolean isShow){
        this.isShow = isShow;
        return this;
    }

    public ProcessBean addProcessVerify(ProcessVerify processVerify){
        this.processVerify = processVerify;
        processVerifyList.add(processVerify);
        return this;
    }
    public ProcessBean addProcessTimeoutCallBack(ProcessTimeout processTimeout){
        this.processTimeout = processTimeout;
        return this;
    }
    public ProcessBean addProcessTimeoutCallBack(int time,ProcessTimeout processTimeout){
        this.processTimeout = processTimeout;
        this.timeout = time;
        return this;
    }

    public ProcessBean addProcessTimeout(int time,ProcessTimeout processTimeout){
        this.processTimeout = processTimeout;
        this.timeout = time;
        this.reTryDo = true;
        return this;
    }
    public ProcessBean addRetry(boolean reTryDo){
        this.reTryDo = reTryDo;
        return this;
    }
    public ProcessBean setTimeout(int timeout){
        this.timeout = timeout;
        return this;
    }
}
